File tree 2 files changed +15
-18
lines changed
2 files changed +15
-18
lines changed Original file line number Diff line number Diff line change @@ -183,13 +183,13 @@ def grd2cpt(grid, **kwargs):
183
183
"""
184
184
if kwargs .get ("W" ) is not None and kwargs .get ("Ww" ) is not None :
185
185
raise GMTInvalidInput ("Set only categorical or cyclic to True, not both." )
186
+
187
+ if (output := kwargs .pop ("H" , None )) is not None :
188
+ kwargs ["H" ] = True
189
+
186
190
with Session () as lib :
187
191
with lib .virtualfile_in (check_kind = "raster" , data = grid ) as vingrd :
188
- if kwargs .get ("H" ) is None : # if no output is set
189
- arg_str = build_arg_list (kwargs , infile = vingrd )
190
- else : # if output is set
191
- outfile , kwargs ["H" ] = kwargs ["H" ], True
192
- if not outfile or not isinstance (outfile , str ):
193
- raise GMTInvalidInput ("'output' should be a proper file name." )
194
- arg_str = build_arg_list (kwargs , infile = vingrd , outfile = outfile )
195
- lib .call_module (module = "grd2cpt" , args = arg_str )
192
+ lib .call_module (
193
+ module = "grd2cpt" ,
194
+ args = build_arg_list (kwargs , infile = vingrd , outfile = output ),
195
+ )
Original file line number Diff line number Diff line change @@ -153,14 +153,11 @@ def makecpt(**kwargs):
153
153
range. Note that ``cyclic=True`` cannot be set together with
154
154
``categorical=True``.
155
155
"""
156
+ if kwargs .get ("W" ) is not None and kwargs .get ("Ww" ) is not None :
157
+ raise GMTInvalidInput ("Set only categorical or cyclic to True, not both." )
158
+
159
+ if (output := kwargs .pop ("H" , None )) is not None :
160
+ kwargs ["H" ] = True
161
+
156
162
with Session () as lib :
157
- if kwargs .get ("W" ) is not None and kwargs .get ("Ww" ) is not None :
158
- raise GMTInvalidInput ("Set only categorical or cyclic to True, not both." )
159
- if kwargs .get ("H" ) is None : # if no output is set
160
- arg_str = build_arg_list (kwargs )
161
- else : # if output is set
162
- outfile , kwargs ["H" ] = kwargs .pop ("H" ), True
163
- if not outfile or not isinstance (outfile , str ):
164
- raise GMTInvalidInput ("'output' should be a proper file name." )
165
- arg_str = build_arg_list (kwargs , outfile = outfile )
166
- lib .call_module (module = "makecpt" , args = arg_str )
163
+ lib .call_module (module = "makecpt" , args = build_arg_list (kwargs , outfile = output ))
You can’t perform that action at this time.
0 commit comments