Embroidery

Embroidery is the art of decorating fabric or other materials with designs using thread or yarn along with a needle. Embroidery may also use other materials such as metal strips, pearls, beads, quills, and sequins.

 

Machine embroidery is performed by special machines which automatically create a design from a pre-made pattern that is fed into the machine. Most embroidery machines are operated through computers that read digitized embroidery files created by special software.

 

In Machine embroidery, the designs are "digitized" with Embroidery Software. Almost all basic types of embroidery can be created with Machine Embroidery. These include: Applique, Free Standing Lace, Cutwork, Cross-stitch, Photo Stitch, and Basic Embroidery. Most often this type of embroidery is associated with business shirts, gifts, team apparel and commercial use.

 

Some embroidery machines are specifically built for industrial purposes. These are tough and can do several stitches in short span of time. Those who are into the embroidery business, should make themselves aware of the newest technologies and designs available as the fast changing fashion makes designs old very fast. The newest technology does not always demand a new machine. Instead new software design can be installed according to the requirements. Many of the softwares designed for embroidery lets a person change an image in digital form to a pattern for embroidery that can be uploaded on the machine.

考虑柔性负荷的综合能源系统低碳经济优化调度【考虑碳交易机制】(Matlab代码实现)内容概要:本文围绕“考虑柔性负荷的综合能源系统低碳经济优化调度”展开,重点研究在碳交易机制下如何实现综合能源系统的低碳化与经济性协同优化。通过构建包含风电、光伏、储能、柔性负荷等多种能源形式的系统模型,结合碳交易成本与能源调度成本,提出优化调度策略,以降低碳排放并提升系统运行经济性。文中采用Matlab进行仿真代码实现,验证了所提模型在平衡能源供需、平抑可再生能源波动、引导柔性负荷参与调度等方面的有效性,为低碳能源系统的设计与运行提供了技术支撑。; 适合人群:具备一定电力系统、能源系统背景,熟悉Matlab编程,从事能源优化、低碳调度、综合能源系统等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①研究碳交易机制对综合能源系统调度决策的影响;②实现柔性负荷在削峰填谷、促进可再生能源消纳中的作用;③掌握基于Matlab的能源系统建模与优化求解方法;④为实际综合能源项目提供低碳经济调度方案参考。; 阅读建议:建议读者结合Matlab代码深入理解模型构建与求解过程,重点关注目标函数设计、约束条件设置及碳交易成本的量化方式,可进一步扩展至多能互补、需求响应等场景进行二次开发与仿真验证。
1.patternType的id写死 这个不会变的 2.不需要使用生成器 3.setUp会使有些函数重复执行 4.测试选用的数据不要都用[0],random随机生成 5.收藏确认断言是收藏的是否是我想要收藏的 class TestPHMutationRegisterFavorite(unittest.TestCase): def setUp(self): self._query_ran=False self._mutation_run=False # self._f_pattern_Id=None # self._article_Id=None # self._font_Id=None def test_query_me_nonexistent_favoritePatterns(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) query = gql( """ query{ me{ favoritePatterns{ id name } } } """ ) try: query_result = client.execute(query) f_pattern = query_result['me']['favoritePatterns'] self.assertIn('id',f_pattern[0]) self.assertIn('name',f_pattern[0]) except Exception as e: print(f":{str(e)}") self._query_ran=True def test_mutation_RegisterFavorite(self): if not self._query_ran: self.test_query_me_nonexistent_favoritePatterns() client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) query_f = gql( """ query{ me{ favoritePatterns{ id name } } } """ ) query_f_result = client.execute(query_f) f_pattern = query_f_result['me']['favoritePatterns'] self._f_pattern_Id = f_pattern[0]['id'] query = gql( """ mutation($favoritePatternId: ID!){ registerFavorite( favoritePatternIds:$favoritePatternId) } """ ) try: query_result = client.execute(query,variable_values={"favoritePatternId":self._f_pattern_Id}) re_fa=query_result['registerFavorite'] self.assertEqual(re_fa,True) self._mutation_run=True except Exception as e: print(f":{str(e)}") def test_query_check_favoritePatterns_after_update(self): if not self._mutation_run: self.test_query_me_nonexistent_favoritePatterns() client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) query = gql( """ query{ me{ favoritePatterns{ id name } } } """ ) try: query_result = client.execute(query) f_pattern = query_result['me']['favoritePatterns'] self.assertIn('id',f_pattern[0]) self.assertIn('name',f_pattern[0]) except Exception as e: print(f":{str(e)}") def test_mutation_RegisterFavorite_article(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) query_a = gql( """ query{ articleTypes{ id } } """ ) query_a_result = client.execute(query_a) a_pattern = query_a_result['articleTypes'] a_pattern_Id = a_pattern[0]['id'] query_a_i=gql( """ query($articleId: ID!){ articlesByArticleTypeId(articleTypeId: $articleId){ id } } """ ) query_a_i_result = client.execute(query_a_i,variable_values={"articleId":a_pattern_Id}) a_pattern = query_a_i_result['articlesByArticleTypeId'] self._article_Id = a_pattern[0]['id'] query = gql( """ mutation($ArticleId: ID!){ registerFavorite( favoritePatternIds:$ArticleId) } """ ) try: query_result = client.execute(query, variable_values={"ArticleId": self._article_Id}) re_fa = query_result['registerFavorite'] self.assertEqual(re_fa, True) except Exception as e: print(f":{str(e)}") def test_mutation_RegisterFavorite_article(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) up_query = gql(""" mutation { updateUser(country: "US") { countryCode } } """) result_up_query=client.execute(up_query) self.assertNotEqual(result_up_query['updateUser']['countryCode'],"JP") query = gql(''' query { me { favoriteContents { __typename ... on Pattern { id } ... on Article { id } } } } ''') result = client.execute(query) favorite_contents=result['me']['favoriteContents'] for item in favorite_contents: if item['__typename'] == 'Pattern': self.assertIn('id' , item, "Pattern missing 'id'") elif item['__typename'] == 'Article': self.assertIn('id' , item, "Article missing 'id'") def test_mutation_RegisterFavorite_favorite_font(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) pattern_type_query = gql(''' query { patternTypes { id name } } ''') pattern_type_result = client.execute(pattern_type_query) pattern_types = pattern_type_result['patternTypes'] # 查找 "Embroidery Fonts" 的 id embroidery_font_type = next((item for item in pattern_types if item['name'] == 'Embroidery Fonts'), None) pattern_type_id = embroidery_font_type['id'] # 2. fonts_query = gql(''' query($patternTypeId: ID!) { fontsByPatternTypeId(patternTypeId: $patternTypeId) { id name } } ''') fonts_data = client.execute(fonts_query, variable_values={"patternTypeId": pattern_type_id}) fonts = fonts_data['fontsByPatternTypeId'] self.assertGreater(len(fonts), 0, "No fonts found for Embroidery Fonts") self._font_Id = fonts[0]["id"] # 3 register_favorite_mutation = gql(''' mutation($favoritePatternId: ID!) { registerFavorite(favoritePatternIds: [$favoritePatternId]) } ''') mutation_result = client.execute(register_favorite_mutation, variable_values={"favoritePatternId": self._font_Id}) self.assertTrue(mutation_result['registerFavorite'], "registerFavorite did not return true") def test_query_RegisterFavorite_font(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) up_query = gql(""" mutation { updateUser(country: "US") { countryCode } } """) result_up_query = client.execute(up_query) self.assertNotEqual(result_up_query['updateUser']['countryCode'], "JP") query = gql( """ query{ me{ favoriteFonts{ id } }} """ ) query_result = client.execute(query) favorite_cont = query_result['me']['favoriteFonts'] # print(favorite_cont) # 指定的字段会被输出确认通过变更指定的ID的数据已被注册在最前面 # favoriteFonts # ": [ # { # "id": "1662f7dc-281a-4f42-b674-b10caab3bb16"最新 # }, # { # "id": "eef41083-4e78-4671-aea1-50fdb15c492c"上一个使用的fontid # } self.assertIn('id', favorite_cont[0]) # self.assertNotEqual(favorite_cont[0],) def test_mutation_RegisterFavorite_article_pattern(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) # 1. articleTypes 的 id query_a = gql(""" query { articleTypes { id } } """) query_a_result = client.execute(query_a) a_pattern = query_a_result['articleTypes'] a_pattern_Id = a_pattern[0]['id'] # 2. articleId query_a_i = gql(""" query($articleId: ID!) { articlesByArticleTypeId(articleTypeId: $articleId) { id } } """) query_a_i_result = client.execute(query_a_i, variable_values={"articleId": a_pattern_Id}) a_pattern_list = query_a_i_result['articlesByArticleTypeId'] article_Id = a_pattern_list[0]['id'] # 3. Fonts" 的 id pattern_type_query = gql(""" query { patternTypes { id name } } """) pattern_type_result = client.execute(pattern_type_query) pattern_types = pattern_type_result['patternTypes'] embroidery_font_type = next( (item for item in pattern_types if item['name'] == 'Embroidery Fonts'), None ) self.assertIsNotNone(embroidery_font_type, "PatternType 'Embroidery Fonts' not found") pattern_type_id = embroidery_font_type['id'] # 4. fontId fonts_query = gql(""" query($patternTypeId: ID!) { fontsByPatternTypeId(patternTypeId: $patternTypeId) { id name } } """) fonts_data = client.execute(fonts_query, variable_values={"patternTypeId": pattern_type_id}) fonts = fonts_data['fontsByPatternTypeId'] self.assertGreater(len(fonts), 0, "No fonts found for Embroidery Fonts") font_Id = fonts[0]['id'] register_favorite_mutation = gql( """ mutation($favoritePatternIds: [ID!]!) { registerFavorite(favoritePatternIds: $favoritePatternIds) } """ ) mutation_result = client.execute( register_favorite_mutation, variable_values={"favoritePatternIds": [article_Id, font_Id]} ) success = mutation_result['registerFavorite'] self.assertTrue(success, "registerFavorite did not return true") def test_mutation_RegisterFavorite_article_pattern_on(self): client=create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) up_query = gql(""" mutation { updateUser(country: "US") { countryCode } } """) result_up_query = client.execute(up_query) self.assertNotEqual(result_up_query['updateUser']['countryCode'], "JP") query = gql(''' query { me { favoriteContents { __typename ... on Pattern { id } ... on Article { id } } } } ''') result = client.execute(query) favorite_contents=result['me']['favoriteContents'] for item in favorite_contents: if item['__typename'] == 'Pattern': self.assertIn('id' , item, "Pattern missing 'id'") elif item['__typename'] == 'Article': self.assertIn('id' , item, "Article missing 'id'") def test_mutation_RegisterFavorite_nonexistent_id(self): client=create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) query=gql( """ mutation{ registerFavorite( favoritePatternIds:"eef41083-4e78-4671-aea1")#不存在的 } """) try: query_result = client.execute(query) except Exception as e: self.assertEqual(e.errors[0]['extensions']['errorCode'], 400, 'errorCode不符合预期') self.assertEqual(e.errors[0]['extensions']['subCode'], 1210, 'subCode不符合预期')
08-07
根据你提供的代码和问题,以下是针对你提到的5个问题的详细解决方案和改进建议: --- ### 1. `patternType` 的 id 写死,这个不会变的 **问题:** 你在多个测试中通过查询 GraphQL 获取 `patternType` 的 id,但实际上你知道这个 id 是固定的,比如 "Embroidery Fonts" 的 id 是不会变的。 **解决方案:** 直接将这个 id 写死,避免不必要的查询请求,提高测试效率和稳定性。 **示例代码:** ```python # 假设已知 Embroidery Fonts 的 id 是固定的 EMBROIDERY_FONTS_ID = "fixed_embroidery_fonts_id_here" ``` **修改建议:** 将查询部分替换为固定值,比如: ```python pattern_type_id = EMBROIDERY_FONTS_ID ``` --- ### 2. 不需要使用生成器 **问题:** 你在多个测试中使用了 `next((item for item in pattern_types if item['name'] == 'Embroidery Fonts'), None)` 这样的生成器表达式,虽然可以工作,但如果你已经知道 id 是固定的,就不需要使用生成器来查找。 **解决方案:** 直接使用写死的 id,不需要遍历查找。 **修改建议:** ```python # 替换掉生成器查找 # embroidery_font_type = next((item for item in pattern_types if item['name'] == 'Embroidery Fonts'), None) # pattern_type_id = embroidery_font_type['id'] pattern_type_id = EMBROIDERY_FONTS_ID ``` --- ### 3. `setUp` 会使有些函数重复执行 **问题:** 你在 `setUp` 中设置了 `self._query_ran`、`self._mutation_run` 等标志变量,用于控制某些测试方法是否已经执行。这会引入副作用,因为 `setUp` 会在每个测试函数执行前运行一次。 **解决方案:** 避免使用标志变量控制测试流程。每个测试方法应独立运行,不依赖其他测试的结果。 **建议:** 将公共部分提取为 helper 函数,而不是在 `setUp` 中调用测试函数。 **示例:** ```python def get_favorite_pattern_id(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) query = gql( """ query { me { favoritePatterns { id name } } } """ ) result = client.execute(query) return result['me']['favoritePatterns'][0]['id'] ``` 然后在测试中调用: ```python def test_mutation_RegisterFavorite(self): favorite_pattern_id = self.get_favorite_pattern_id() ``` --- ### 4. 测试选用的数据不要都用 `[0]`,random 随机生成 **问题:** 你总是使用第一个元素 `item[0]`,这可能导致测试数据单一,无法覆盖更多情况。 **解决方案:** 使用 `random.choice()` 从列表中随机选取一个元素,提高测试的多样性。 **示例代码:** ```python import random def get_random_favorite_pattern_id(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) query = gql( """ query { me { favoritePatterns { id } } } """ ) result = client.execute(query) return random.choice(result['me']['favoritePatterns'])['id'] ``` --- ### 5. 收藏确认断言是收藏的是否是我想要收藏的 **问题:** 你在测试中只验证了 `registerFavorite` 返回为 `True`,但没有确认是否真的收藏了你传入的那个 `id`。 **解决方案:** 在注册收藏后,再次查询 `me.favoriteContents`,并确认返回结果中包含你刚刚注册的那个 `id`。 **示例代码:** ```python def test_mutation_RegisterFavorite(self): client = create_graphql_client(GRAPHQL_ENDPOINT_URL, REQUEST_HEADER) favorite_pattern_id = self.get_favorite_pattern_id() # 执行收藏操作 mutation = gql( """ mutation($favoritePatternId: ID!) { registerFavorite(favoritePatternIds: [$favoritePatternId]) } """ ) client.execute(mutation, variable_values={"favoritePatternId": favorite_pattern_id}) # 查询收藏内容,确认包含该 id query = gql( """ query { me { favoriteContents { __typename ... on Pattern { id } } } } """ ) result = client.execute(query) favorite_ids = [item['id'] for item in result['me']['favoriteContents'] if item['__typename'] == 'Pattern'] self.assertIn(favorite_pattern_id, favorite_ids, "注册的收藏 id 未出现在 favoriteContents 中") ``` --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值