Skip to content

Commit 18ad0e0

Browse files
authored
Merge pull request #5 from greschd/use_lambda_for_defaults
Convert 'default' values to callables.
2 parents f901818 + 44cce06 commit 18ad0e0

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

aiida_wannier90_workflows/workflows/band_structure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def define(cls, spec):
3838
help='The input structure.')
3939
spec.input('options', valid_type=orm.Dict, required=False,
4040
help='Optional `options` to use for the `PwCalculations`.')
41-
spec.input('protocol', valid_type=orm.Dict, default=orm.Dict(dict={'name': 'theos-ht-1.0'}),
41+
spec.input('protocol', valid_type=orm.Dict, default=lambda: orm.Dict(dict={'name': 'theos-ht-1.0'}),
4242
help='The protocol to use for the workchain.', validator=validate_protocol)
4343
spec.expose_outputs(PwBandsWorkChain)
4444
spec.outline(

aiida_wannier90_workflows/workflows/wannier.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ class Wannier90WorkChain(WorkChain):
1515
"""
1616
Workchain to obtain maximally localised Wannier functions (MLWF)
1717
Authors: Antimo Marrazzo (antimo.marrazzo@epfl.ch), Giovanni Pizzi (giovanni.pizzi@epfl.ch), Junfeng Qiao(junfeng.qiao@epfl.ch)
18-
18+
1919
MIT License - Copyright (c), 2018, ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE
20-
(Theory and Simulation of Materials (THEOS) and National Centre for
20+
(Theory and Simulation of Materials (THEOS) and National Centre for
2121
Computational Design and Discovery of Novel Materials (NCCR MARVEL)).
2222
All rights reserved.
2323
24-
Scheme: setup --> relax(optional) --> scf --> nscf --> projwfc
24+
Scheme: setup --> relax(optional) --> scf --> nscf --> projwfc
2525
-> wannier90_postproc --> pw2wannier90 --> wannier90 --> results
26-
27-
This is a very basic workchain, in that user needs to specify
28-
inputs of every step. Please consider using Wannier90BandsWorkChain,
26+
27+
This is a very basic workchain, in that user needs to specify
28+
inputs of every step. Please consider using Wannier90BandsWorkChain,
2929
which automatically generates inputs.
3030
"""
3131
@classmethod
@@ -39,33 +39,32 @@ def define(cls, spec):
3939
spec.input(
4040
'clean_workdir',
4141
valid_type=orm.Bool,
42-
default=orm.Bool(False),
42+
default=lambda: orm.Bool(False),
4343
help=
4444
'If `True`, work directories of all called calculation will be cleaned at the end of execution.'
4545
)
4646
spec.input(
4747
'only_valence',
4848
valid_type=orm.Bool,
49-
default=orm.Bool(False),
49+
default=lambda: orm.Bool(False),
5050
help='Whether only wannierise valence band or not'
5151
)
5252
spec.input(
5353
'wannier_energies_relative_to_fermi',
5454
valid_type=orm.Bool,
55-
default=orm.Bool(False),
55+
default=lambda: orm.Bool(False),
5656
help=
5757
'determines if the energies(dis_froz_min/max, dis_win_min/max) defined in the input parameters '
5858
+ 'are relative to scf Fermi energy or not.'
5959
)
6060
spec.input(
6161
'scdm_thresholds',
6262
valid_type=orm.Dict,
63-
default=orm.Dict(
64-
dict={
65-
'max_projectability': 0.95,
66-
'sigma_factor': 3
67-
}
68-
),
63+
default=lambda: orm.
64+
Dict(dict={
65+
'max_projectability': 0.95,
66+
'sigma_factor': 3
67+
}),
6968
help='can contain two keyword: max_projectability, sigma_factor'
7069
)
7170
spec.expose_inputs(
@@ -415,7 +414,7 @@ def inspect_nscf(self):
415414

416415
def should_do_projwfc(self):
417416
"""
418-
If the 'auto_projections = true' && only_valence, we
417+
If the 'auto_projections = true' && only_valence, we
419418
run projwfc calculation to extract SCDM mu & sigma.
420419
"""
421420
self.report("SCDM mu & sigma are auto-set using projectability")
@@ -459,7 +458,7 @@ def inspect_projwfc(self):
459458

460459
def run_wannier90_pp(self):
461460
"""The input of wannier90 calculation is build here.
462-
461+
463462
:return: [description]
464463
:rtype: [type]
465464
"""
@@ -582,7 +581,8 @@ def run_pw2wannier90(self):
582581
try:
583582
inputs.parameters = update_pw2wan_params_mu_sigma(
584583
parameters=orm.Dict(dict=inputs.parameters),
585-
wannier_parameters=self.ctx.calc_wannier90_pp.inputs.parameters,
584+
wannier_parameters=self.ctx.calc_wannier90_pp.inputs.
585+
parameters,
586586
bands=self.ctx.calc_projwfc.outputs.bands,
587587
projections=self.ctx.calc_projwfc.outputs.projections,
588588
thresholds=self.inputs.get('scdm_thresholds')
@@ -776,7 +776,7 @@ def results(self):
776776
@calcfunction
777777
def convert_kpoints_mesh_to_list(kmesh):
778778
"""works just like kmesh.pl in Wannier90
779-
779+
780780
:param kmesh: [description]
781781
:type kmesh: KpointsData
782782
:raises ValueError: [description]
@@ -900,7 +900,7 @@ def get_nprojs_from_upf(upf):
900900

901901
def get_exclude_bands(parameters):
902902
"""get exclude_bands from Wannier90 parameters
903-
903+
904904
:param parameters: Wannier90Calculation input parameters
905905
:type parameters: dict, NOT Dict, this is not a calcfunction
906906
:return: the indices of the bands to be excluded
@@ -912,7 +912,7 @@ def get_exclude_bands(parameters):
912912

913913
def get_keep_bands(parameters):
914914
"""get keep_bands from Wannier90 parameters
915-
915+
916916
:param parameters: Wannier90Calculation input parameters
917917
:type parameters: dict, NOT Dict, this is not a calcfunction
918918
:return: the indices of the bands to be kept
@@ -935,12 +935,12 @@ def update_w90_params_fermi(
935935
):
936936
"""
937937
Updated W90 windows with the specified Fermi energy.
938-
938+
939939
:param parameters: Wannier90Calculation input parameters
940940
:type parameters: Dict
941941
:param fermi_energy: [description]
942942
:type fermi_energy: Float
943-
:param relative_to_fermi: if energies in input parameters are defined relative
943+
:param relative_to_fermi: if energies in input parameters are defined relative
944944
scf Fermi energy.
945945
:type relative_to_fermi: Bool
946946
:return: updated parameters
@@ -1020,7 +1020,7 @@ def update_pw2wan_params_mu_sigma(
10201020
parameters, wannier_parameters, bands, projections, thresholds
10211021
):
10221022
"""[summary]
1023-
1023+
10241024
:param pw2wan_parameters: [description]
10251025
:type pw2wan_parameters: Dict
10261026
:param mu_sigma: [description]

0 commit comments

Comments
 (0)