Skip to content

Commit 9a77f2f

Browse files
committed
Merge branch 'SC-2390' into 'develop'
SC-2390: Fix argument default value handling See merge request SOLO-band/python-sdk!96
2 parents ad97871 + 1ff34f8 commit 9a77f2f

File tree

1 file changed

+161
-90
lines changed

1 file changed

+161
-90
lines changed

src/rogii_solo/well.py

+161-90
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from rogii_solo.types import DataList
1919
from rogii_solo.utils.objects import find_by_uuid
2020

21+
keep_value = object()
22+
2123

2224
class Well(ComplexObject):
2325
def __init__(self, papi_client: PapiClient, project: 'rogii_solo.project.Project', **kwargs):
@@ -72,28 +74,40 @@ def to_dict(self, get_converted: bool = True) -> Dict[str, Any]:
7274
'name': self.name,
7375
'api': self.api,
7476
'operator': self.operator,
75-
'xsrf': self.safe_round(self.convert_xy(value=self.xsrf, measure_units=measure_units, force_to_meters=True))
76-
if get_converted
77-
else self.xsrf,
78-
'ysrf': self.safe_round(self.convert_xy(value=self.ysrf, measure_units=measure_units, force_to_meters=True))
79-
if get_converted
80-
else self.ysrf,
77+
'xsrf': (
78+
self.safe_round(self.convert_xy(value=self.xsrf, measure_units=measure_units, force_to_meters=True))
79+
if get_converted
80+
else self.xsrf
81+
),
82+
'ysrf': (
83+
self.safe_round(self.convert_xy(value=self.ysrf, measure_units=measure_units, force_to_meters=True))
84+
if get_converted
85+
else self.ysrf
86+
),
8187
'xsrf_real': self.safe_round(self.xsrf_real) if get_converted else feet_to_meters(self.xsrf_real),
8288
'ysrf_real': self.safe_round(self.ysrf_real) if get_converted else feet_to_meters(self.ysrf_real),
83-
'kb': self.safe_round(self.convert_z(value=self.kb, measure_units=measure_units))
84-
if get_converted
85-
else self.kb,
89+
'kb': (
90+
self.safe_round(self.convert_z(value=self.kb, measure_units=measure_units))
91+
if get_converted
92+
else self.kb
93+
),
8694
'azimuth': self.safe_round(self.convert_angle(self.azimuth)) if get_converted else self.azimuth,
8795
'convergence': self.safe_round(self.convert_angle(self.convergence)) if get_converted else self.convergence,
88-
'tie_in_tvd': self.safe_round(self.convert_z(value=self.tie_in_tvd, measure_units=measure_units))
89-
if get_converted
90-
else self.tie_in_tvd,
91-
'tie_in_ns': self.safe_round(self.convert_xy(value=self.tie_in_ns, measure_units=measure_units))
92-
if get_converted
93-
else self.tie_in_ns,
94-
'tie_in_ew': self.safe_round(self.convert_xy(value=self.tie_in_ew, measure_units=measure_units))
95-
if get_converted
96-
else self.tie_in_ew,
96+
'tie_in_tvd': (
97+
self.safe_round(self.convert_z(value=self.tie_in_tvd, measure_units=measure_units))
98+
if get_converted
99+
else self.tie_in_tvd
100+
),
101+
'tie_in_ns': (
102+
self.safe_round(self.convert_xy(value=self.tie_in_ns, measure_units=measure_units))
103+
if get_converted
104+
else self.tie_in_ns
105+
),
106+
'tie_in_ew': (
107+
self.safe_round(self.convert_xy(value=self.tie_in_ew, measure_units=measure_units))
108+
if get_converted
109+
else self.tie_in_ew
110+
),
97111
'starred': self.starred,
98112
}
99113

@@ -362,7 +376,14 @@ def create_log(self, name: str, points: DataList):
362376
self._papi_client.replace_log(log_id=log_id['uuid'], index_unit=units, log_points=prepared_points)
363377

364378
if self._logs is not None:
365-
self._logs.append(Log(papi_client=self._papi_client, well=self, uuid=log_id['uuid'], name=name))
379+
self._logs.append(
380+
Log(
381+
papi_client=self._papi_client,
382+
well=self,
383+
uuid=log_id['uuid'],
384+
name=name,
385+
)
386+
)
366387

367388
def create_target_line(
368389
self,
@@ -387,39 +408,42 @@ def create_target_line(
387408

388409
# No raw method for target line
389410
target_line_data = find_by_uuid(
390-
value=target_line_id['uuid'], input_list=self._papi_client.get_well_target_lines_data(well_id=self.uuid)
411+
value=target_line_id['uuid'],
412+
input_list=self._papi_client.get_well_target_lines_data(well_id=self.uuid),
391413
)
392414

393415
if self._target_lines is not None:
394416
self._target_lines.append(TargetLine(**target_line_data))
395417

396418
def update_meta(
397419
self,
398-
name: Optional[str] = None,
399-
operator: Optional[str] = None,
400-
api: Optional[str] = None,
401-
xsrf: Optional[float] = None,
402-
ysrf: Optional[float] = None,
403-
kb: Optional[float] = None,
404-
azimuth: Optional[float] = None,
405-
convergence: Optional[float] = None,
406-
tie_in_tvd: Optional[float] = None,
407-
tie_in_ns: Optional[float] = None,
408-
tie_in_ew: Optional[float] = None,
420+
name: Optional[str] = keep_value,
421+
operator: Optional[str] = keep_value,
422+
api: Optional[str] = keep_value,
423+
xsrf: Optional[float] = keep_value,
424+
ysrf: Optional[float] = keep_value,
425+
kb: Optional[float] = keep_value,
426+
azimuth: Optional[float] = keep_value,
427+
convergence: Optional[float] = keep_value,
428+
tie_in_tvd: Optional[float] = keep_value,
429+
tie_in_ns: Optional[float] = keep_value,
430+
tie_in_ew: Optional[float] = keep_value,
409431
):
410432
is_updated = self._papi_client.update_well_meta(
411433
well_id=self.uuid,
412-
name=name,
413-
api=api,
414-
operator=operator,
415-
xsrf=self._papi_client.prepare_papi_var(xsrf),
416-
ysrf=self._papi_client.prepare_papi_var(ysrf),
417-
kb=self._papi_client.prepare_papi_var(kb),
418-
azimuth=self._papi_client.prepare_papi_var(azimuth),
419-
convergence=self._papi_client.prepare_papi_var(convergence),
420-
tie_in_tvd=self._papi_client.prepare_papi_var(tie_in_tvd),
421-
tie_in_ns=self._papi_client.prepare_papi_var(tie_in_ns),
422-
tie_in_ew=self._papi_client.prepare_papi_var(tie_in_ew),
434+
name=self.name if name is keep_value else name,
435+
api=self.api if api is keep_value else api,
436+
operator=self.operator if operator is keep_value else operator,
437+
xsrf=self._papi_client.prepare_papi_var(self.xsrf if xsrf is keep_value else xsrf),
438+
ysrf=self._papi_client.prepare_papi_var(self.ysrf if ysrf is keep_value else ysrf),
439+
kb=self._papi_client.prepare_papi_var(self.kb if kb is keep_value else kb),
440+
azimuth=self._papi_client.prepare_papi_var(self.azimuth if azimuth is keep_value else azimuth),
441+
convergence=self._papi_client.prepare_papi_var(
442+
self.convergence if convergence is keep_value else convergence
443+
),
444+
tie_in_tvd=self._papi_client.prepare_papi_var(self.tie_in_tvd if tie_in_tvd is keep_value else tie_in_tvd),
445+
tie_in_ns=self._papi_client.prepare_papi_var(self.tie_in_ns if tie_in_ns is keep_value else tie_in_ns),
446+
tie_in_ew=self._papi_client.prepare_papi_var(self.tie_in_ew if tie_in_ew is keep_value else tie_in_ew),
423447
)
424448

425449
if is_updated:
@@ -443,15 +467,17 @@ def to_dict(self, get_converted: bool = True) -> Dict:
443467
'Name': data['Name'],
444468
'API': data['API'],
445469
'Operator': data['Operator'],
446-
'KB': self.safe_round(self.convert_z(value=data['KB'], measure_units=measure_units))
447-
if get_converted
448-
else data['KB'],
449-
'Azimuth VS': self.safe_round(self.convert_angle(data['Azimuth VS']))
450-
if get_converted
451-
else data['Azimuth VS'],
452-
'Convergence': self.safe_round(self.convert_angle(data['Convergence']))
453-
if get_converted
454-
else data['Convergence'],
470+
'KB': (
471+
self.safe_round(self.convert_z(value=data['KB'], measure_units=measure_units))
472+
if get_converted
473+
else data['KB']
474+
),
475+
'Azimuth VS': (
476+
self.safe_round(self.convert_angle(data['Azimuth VS'])) if get_converted else data['Azimuth VS']
477+
),
478+
'Convergence': (
479+
self.safe_round(self.convert_angle(data['Convergence'])) if get_converted else data['Convergence']
480+
),
455481
'X-srf': self.safe_round(data['X-srf']) if get_converted else feet_to_meters(data['X-srf']),
456482
'Y-srf': self.safe_round(data['Y-srf']) if get_converted else feet_to_meters(data['Y-srf']),
457483
}
@@ -501,28 +527,40 @@ def to_dict(self, get_converted: bool = True) -> Dict[str, Any]:
501527
'name': self.name,
502528
'api': self.api,
503529
'operator': self.operator,
504-
'xsrf': self.safe_round(self.convert_xy(value=self.xsrf, measure_units=measure_units, force_to_meters=True))
505-
if get_converted
506-
else self.xsrf,
507-
'ysrf': self.safe_round(self.convert_xy(value=self.ysrf, measure_units=measure_units, force_to_meters=True))
508-
if get_converted
509-
else self.ysrf,
530+
'xsrf': (
531+
self.safe_round(self.convert_xy(value=self.xsrf, measure_units=measure_units, force_to_meters=True))
532+
if get_converted
533+
else self.xsrf
534+
),
535+
'ysrf': (
536+
self.safe_round(self.convert_xy(value=self.ysrf, measure_units=measure_units, force_to_meters=True))
537+
if get_converted
538+
else self.ysrf
539+
),
510540
'xsrf_real': self.safe_round(self.xsrf_real) if get_converted else feet_to_meters(self.xsrf_real),
511541
'ysrf_real': self.safe_round(self.ysrf_real) if get_converted else feet_to_meters(self.ysrf_real),
512-
'kb': self.safe_round(self.convert_z(value=self.kb, measure_units=measure_units))
513-
if get_converted
514-
else self.kb,
542+
'kb': (
543+
self.safe_round(self.convert_z(value=self.kb, measure_units=measure_units))
544+
if get_converted
545+
else self.kb
546+
),
515547
'azimuth': self.safe_round(self.convert_angle(self.azimuth)) if get_converted else self.azimuth,
516548
'convergence': self.safe_round(self.convert_angle(self.convergence)) if get_converted else self.convergence,
517-
'tie_in_tvd': self.safe_round(self.convert_z(value=self.tie_in_tvd, measure_units=measure_units))
518-
if get_converted
519-
else self.tie_in_tvd,
520-
'tie_in_ns': self.safe_round(self.convert_xy(value=self.tie_in_ns, measure_units=measure_units))
521-
if get_converted
522-
else self.tie_in_ns,
523-
'tie_in_ew': self.safe_round(self.convert_xy(value=self.tie_in_ew, measure_units=measure_units))
524-
if get_converted
525-
else self.tie_in_ew,
549+
'tie_in_tvd': (
550+
self.safe_round(self.convert_z(value=self.tie_in_tvd, measure_units=measure_units))
551+
if get_converted
552+
else self.tie_in_tvd
553+
),
554+
'tie_in_ns': (
555+
self.safe_round(self.convert_xy(value=self.tie_in_ns, measure_units=measure_units))
556+
if get_converted
557+
else self.tie_in_ns
558+
),
559+
'tie_in_ew': (
560+
self.safe_round(self.convert_xy(value=self.tie_in_ew, measure_units=measure_units))
561+
if get_converted
562+
else self.tie_in_ew
563+
),
526564
}
527565

528566
def to_df(self, get_converted: bool = True) -> DataFrame:
@@ -580,7 +618,14 @@ def create_topset(self, name: str):
580618
topset_id = self._papi_client.create_nested_well_topset(nested_well_id=self.uuid, name=name)
581619

582620
if self._topsets is not None:
583-
self._topsets.append(Topset(papi_client=self._papi_client, well=self, uuid=topset_id['uuid'], name=name))
621+
self._topsets.append(
622+
Topset(
623+
papi_client=self._papi_client,
624+
well=self,
625+
uuid=topset_id['uuid'],
626+
name=name,
627+
)
628+
)
584629

585630
def update_meta(
586631
self,
@@ -660,27 +705,39 @@ def to_dict(self, get_converted: bool = True) -> Dict[str, Any]:
660705
'name': self.name,
661706
'api': self.api,
662707
'operator': self.operator,
663-
'xsrf': self.safe_round(self.convert_xy(value=self.xsrf, measure_units=measure_units, force_to_meters=True))
664-
if get_converted
665-
else self.xsrf,
666-
'ysrf': self.safe_round(self.convert_xy(value=self.ysrf, measure_units=measure_units, force_to_meters=True))
667-
if get_converted
668-
else self.ysrf,
708+
'xsrf': (
709+
self.safe_round(self.convert_xy(value=self.xsrf, measure_units=measure_units, force_to_meters=True))
710+
if get_converted
711+
else self.xsrf
712+
),
713+
'ysrf': (
714+
self.safe_round(self.convert_xy(value=self.ysrf, measure_units=measure_units, force_to_meters=True))
715+
if get_converted
716+
else self.ysrf
717+
),
669718
'xsrf_real': self.safe_round(self.xsrf_real) if get_converted else feet_to_meters(self.xsrf_real),
670719
'ysrf_real': self.safe_round(self.ysrf_real) if get_converted else feet_to_meters(self.ysrf_real),
671-
'kb': self.safe_round(self.convert_z(value=self.kb, measure_units=measure_units))
672-
if get_converted
673-
else self.kb,
720+
'kb': (
721+
self.safe_round(self.convert_z(value=self.kb, measure_units=measure_units))
722+
if get_converted
723+
else self.kb
724+
),
674725
'convergence': self.safe_round(self.convert_angle(self.convergence)) if get_converted else self.convergence,
675-
'tie_in_tvd': self.safe_round(self.convert_z(value=self.tie_in_tvd, measure_units=measure_units))
676-
if get_converted
677-
else self.tie_in_tvd,
678-
'tie_in_ns': self.safe_round(self.convert_xy(value=self.tie_in_ns, measure_units=measure_units))
679-
if get_converted
680-
else self.tie_in_ns,
681-
'tie_in_ew': self.safe_round(self.convert_xy(value=self.tie_in_ew, measure_units=measure_units))
682-
if get_converted
683-
else self.tie_in_ew,
726+
'tie_in_tvd': (
727+
self.safe_round(self.convert_z(value=self.tie_in_tvd, measure_units=measure_units))
728+
if get_converted
729+
else self.tie_in_tvd
730+
),
731+
'tie_in_ns': (
732+
self.safe_round(self.convert_xy(value=self.tie_in_ns, measure_units=measure_units))
733+
if get_converted
734+
else self.tie_in_ns
735+
),
736+
'tie_in_ew': (
737+
self.safe_round(self.convert_xy(value=self.tie_in_ew, measure_units=measure_units))
738+
if get_converted
739+
else self.tie_in_ew
740+
),
684741
# Shift is returned in project units
685742
'shift': self.safe_round(self.shift) if get_converted else feet_to_meters(value=self.shift),
686743
}
@@ -785,7 +842,14 @@ def create_topset(self, name: str):
785842
topset_id = self._papi_client.create_typewell_topset(typewell_id=self.uuid, name=name)
786843

787844
if self._topsets is not None:
788-
self._topsets.append(Topset(papi_client=self._papi_client, well=self, uuid=topset_id['uuid'], name=name))
845+
self._topsets.append(
846+
Topset(
847+
papi_client=self._papi_client,
848+
well=self,
849+
uuid=topset_id['uuid'],
850+
name=name,
851+
)
852+
)
789853

790854
def create_log(self, name: str, points: DataList):
791855
log_id = self._papi_client.create_typewell_log(typewell_id=self.uuid, name=name)
@@ -797,4 +861,11 @@ def create_log(self, name: str, points: DataList):
797861
self._papi_client.replace_log(log_id=log_id['uuid'], index_unit=units, log_points=prepared_points)
798862

799863
if self._logs is not None:
800-
self._logs.append(Log(papi_client=self._papi_client, well=self, uuid=log_id['uuid'], name=name))
864+
self._logs.append(
865+
Log(
866+
papi_client=self._papi_client,
867+
well=self,
868+
uuid=log_id['uuid'],
869+
name=name,
870+
)
871+
)

0 commit comments

Comments
 (0)